<?php

namespace Controller;

use Lib\Request;

class Pages extends App {

    public function show($id, $title=null) {
        $this->loadModel('Page');

        if ($id > 0) {
            $page = $this->Page->get($id);
        } else {
            $page = $this->Page->first();
            if (! $page) {
                $this->redirect('/kontakt');
            }
        }

        if (! empty($page['background'])) {
            $this->setBodyBackground($page['background']);
        }

        $this->title = $page['title'];
        $this->set('page', $page);
    }

}

?>